nclude <stdio.h>
#include <sys/types.h>          
#include <sys/socket.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <unistd.h>
#include <signal.h>
#include <arpa/inet.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include "sem.h"
#include <termios.h>
#include <fcntl.h>
#include <sys/stat.h>
#define SEND_OK 0xAA
#include <pthread.h>
#include <stdint.h>



void serial_init(int fd)
{
		struct termios options;
			tcgetattr(fd, &options);
				options.c_cflag |= ( CLOCAL | CREAD );
					options.c_cflag &= ~CSIZE;
						options.c_cflag &= ~CRTSCTS;
							options.c_cflag |= CS8;
								options.c_cflag &= ~CSTOPB;
									options.c_iflag |= IGNPAR;
										options.c_iflag &= ~(ICRNL | IXON);
											options.c_oflag = 0;
												options.c_lflag = 0;
													cfsetispeed(&options, B115200);
														cfsetospeed(&options, B115200);
															tcsetattr(fd,TCSANOW,&options);
}


typedef struct
{
		uint8_t head[3];	 //标识位st:
			uint8_t type;		 //数据类型
				uint8_t snum;		 //仓库编号
					uint8_t temp[2];	 //温度	
						uint8_t hum[2];		 //湿度
							uint8_t x;			 //三轴信息
								uint8_t y;			 
									uint8_t z;			 
										uint32_t ill;		 //光照
											uint32_t bet;		 //电池电量
												uint32_t adc; 		 //电位器信息
}sendEnv;



int main(int argc, const char *argv[])
{
	int dev_uart_fd;
	if((dev_uart_fd = open("/dev/ttyUSB0", O_RDWR)) < 0)
	{
		perror("uart uart err");
		return -1;
	}
	serial_init(dev_uart_fd);
	int x = 0x21;
	write(dev_uart_fd, x, 4);

		return 0;
}
